home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 14.5 KB | 451 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: Print.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.5+> 11/19/93 NAGA modify TCS format
- # <1.0.5> 8/25/93 KTA Added support for parity checking the TCS stack.
- # <1.0.4> 7/19/93 KTA Updates for FindWindow() to handle descriptors.
- # <1.0.3> 7/14/93 KTA International Support: See Printer(), and PageSetUp().
- # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Output.Lib","TCS.Lib","UserInterface.Lib";
-
- #########################################################################
- # PageSetup.lib
- #========================================================================
- # Description: This file contains Task to test the page setup dialog.
- # Currently only TestPageSetup() should be called. The
- # other Tasks are support for this Task.
- #
- # Tasks:
- # TestPageSetup(checkBoxTest,paperSizeTest,pageSizeTest,orientationTest,printTest)
- # TestCheckBoxList(checkBoxList)
- # PaperSize()
- # PageSize()
- # ToggleOrientation()
- # PrintSample()
- #
- # Copyright Apple Computer, Inc. 1985-1990
- # All rights reserved
- #========================================================================
- # ECH 11/29/90 Created
- #########################################################################
-
-
- #########################################################################
- # TestPageSetup(checkBoxTest,paperSizeTest,pageSizeTest,orientationTest,printTest)
- #========================================================================
- # Author: Eric Hewitt
- # Description: Tests the standard page setup. All permutations of
- # checkboxes, paper radio buttons, scale controls, and
- # orientation icons are selected.
- # Parameters: checkBoxTest - 0 = do not test checkboxes
- # 1 = test check boxes
- # paperSizeTest - 0 = do not test paper sizes
- # 1 = test paper sizes
- # pageSizeTest - 0 = do not test page sizes
- # 1 = test page sizes
- # orientationTest - 0 = do not test orientation
- # 1 = test orientation
- # printTest - 0 = do not print after each combination
- # 1 = perform print test after each combination
- # Returns: 0 = Error occured in testing
- # 1 = Successful test
- # Examples: TestPageSetup(1,0,0,1,0);
- # Assumptions: A Page Setup dialog is up.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK TestPageSetup(checkBoxTest := 1,paperSizeTest := 1,pageSizeTest := 1,orientationTest := 1,printTest := 0)
- begin
- (* ** Sample Printer Entry **
- Parameters := { Printer Name,
- list of check box names,
- list of paper size radio button names,
- list of page size radio button names,
- or 0 if size is a text entry field
- or if page size is changed by up and down controls, a list
- with first element = # of possible values and the next
- two = location of controls,
- location of portrait orientation control relative to the window,
- location of lanscape orientation control relative to the window
- };
- *)
- PrinterList := {
- { 'LaserWriter Page Setup',
- { 'Font Substitution?','Text Smoothing?','Graphics Smoothing?','Faster Bitmap Printing?' },
- { 'US Letter','US Legal','A4 Letter','B5 Letter','' },
- 0, # Text field
- { 80,135 },
- { 115,135 }
- },
- { 'Personal LaserWriter LS',
- { 'Precision Bitmap Alignment' },
- { 'US Letter','US Legal','A4 Letter','B5 Letter','No. 10 Envelope' },
- { '100%','75%','50%' },
- { 40,120 },
- { 80,120 }
- },
- { 'Personal LaserWriter SC',
- { 'Exact Bit Images (Shrink 4%)','Text Smoothing' },
- { 'US Letter','US Legal','A4 Letter','B5 Letter','No. 10 Envelope' },
- { '100%','75%','50%' },
- { 30,115 },
- { 70,115 }
- },
- { 'Tabasco',
- { },
- { 'US Letter','US Legal','A4 Letter','Envelope (#10)' },
- { 5,{ 317,93 },{ 317,83 } }, # up and down controls
- { 120,100 },
- { 160,100 }
- }
- };
-
- ### Check to see if the page setup dialog is for a known printer
- for i := 1 to card printerList
- if (match [staticText t:printerList[i][1]]!)
- begin
- printerName := printerList[i][1];
- global printerParameters := printerList[i];
- global testCheckBoxes := checkBoxTest;
- global testPaperSize := paperSizeTest;
- global testPageSize := pageSizeTest;
- global testOrientation := orientationTest;
- global testPrint := printTest;
- LogStr("====================================================================");
- LogStr("Testing PageSetup for {printerName}");
- ### First excercise the checkboxes, then paper size radio buttons, page
- ### size controls, and orientation controls.
- TestCheckBoxList(printerList[i][2]);
-
- ### excercise help
- if (match [button t:'Help']!)
- begin
- LogStr("Testing Help");
- if (SelectButton('Help'))
- begin
- wait(2);
- SelectButton('OK');
- end;
- end;
-
- ### successful test
- return(1);
- end;
-
- ### No match on any of the known printers
- LogStr("*** Unknown Printer type ***");
- return(0);
- end;
-
-
- #########################################################################
- # TestCheckBoxList(printerParameters)
- #========================================================================
- # Author: Eric Hewitt
- # Description: Selects all possible combinations of check boxes by
- # recursive calls to itself. After each combination, it
- # calls PaperSize() which will result in all possible
- # combinations of check boxes, paper sizes, page sizes, and
- # orientations.
- # Parameters: checkBoxList - A list of check box names
- # Returns: Nothing
- #========================================================================
- # History:
- #
- #########################################################################
- TASK TestCheckBoxList(checkBoxList)
- begin
- if (global testCheckBoxes)
- begin
- if (card checkBoxList = 0)
- begin
- PaperSize();
- return(0);
- end;
- else
- for a := 1 to 2
- begin
- TestCheckBoxList(remove(1,checkBoxList));
- SelectCheckBox(checkBoxList[1]);
- end;
- end;
- else
- PaperSize();
- end;
-
-
- #########################################################################
- # PaperSize()
- #========================================================================
- # Author: Eric Hewitt
- # Description: Selects all the paper size radio buttons. After selecting
- # each button, it calls PageSize() to go through all possible
- # page sizes and then orientations. This exercises all
- # possible combinations of paper size, page size, and
- # orientation.
- # Parameters: None
- # Returns: Nothing
- #========================================================================
- # History:
- #
- #########################################################################
- TASK PaperSize()
- begin
- global printerParameters;
-
- if (global testPaperSize)
- begin
- for a := 1 to card printerParameters[3]
- begin
- SelectRadioButton(printerParameters[3][a]);
- PageSize();
- end;
- end;
- else
- PageSize();
- end;
-
-
- #########################################################################
- # PageSize()
- #========================================================================
- # Author: Eric Hewitt
- # Description: Selects the paper size in one of either three ways: Typing
- # values in a text edit field, selecting an up and down
- # control, or by selecting radio buttons. In between each
- # page size, this function calls ToggleOrientation.
- # Parameters: None
- # Returns: Nothing
- #========================================================================
- # History:
- #
- #########################################################################
- TASK PageSize()
- begin
- global printerParameters;
-
- if (global testPageSize)
- begin
- if (printerParameters[4] = 0)
- begin
- ### Text entry field so type in values 100,80,60,40,20
- for b := 100 to 20 step -20
- begin
- # erase old value
- type k:{ backspacekey,backspacekey,backspacekey };
- # type in new value
- TypeStr("{b}");
- # Change orientation
- ToggleOrientation();
- end;
- end;
- else if (TypeOf(printerParameters[4][1]) = 'integer')
- begin
- ### Up and down arrow controls to select size
- for b := 1 to printerParameters[4][1]
- begin
- # Select down control
- temp := global gDisableAllLogging;
- global gDisableAllLogging := 1;
- MoveRelativeToWindow(printerParameters[4][2][1],printerParameters[4][2][2],1,2);
- global gDisableAllLogging := temp;
- LogStr("Pressed scale down control");
- ToggleOrientation();
- end;
- for b := 1 to printerParameters[4][1]
- begin
- # reset control by selecting up
- temp := global gDisableAllLogging;
- global gDisableAllLogging := 1;
- MoveRelativeToWindow(printerParameters[4][3][1],printerParameters[4][3][2],1,2);
- global gDisableAllLogging := temp;
- LogStr("Pressed scale up control");
- end;
- end;
- else
- ### There are radio buttons to select size
- for b := 1 to card printerParameters[4]
- begin
- SelectRadioButton(printerParameters[4][b]);
- ToggleOrientation();
- end;
- end;
- else
- ToggleOrientation();
- end;
-
-
- #########################################################################
- # ToggleOrientation()
- #========================================================================
- # Author: Eric Hewitt
- # Description: Toggles the portrait and landscape icons.
- # Parameters: None
- # Returns: Nothing
- # Examples: ToggleOrientation();
- #========================================================================
- # History:
- #
- #########################################################################
- TASK ToggleOrientation()
- begin
- global printerParameters;
-
- if (global testOrientation)
- begin
- temp := global gDisableAllLogging;
- global gDisableAllLogging := 1;
- MoveRelativeToWindow(printerParameters[5][1],printerParameters[5][2],1,2);
- global gDisableAllLogging := 0;
- LogStr("Pressed Portrait control");
- PrintSample();
- global gDisableAllLogging := 1;
- MoveRelativeToWindow(printerParameters[6][1],printerParameters[6][2],1,2);
- global gDisableAllLogging := temp;
- LogStr("Pressed Landscape control");
- PrintSample();
- end;
- end;
-
-
- #########################################################################
- # PrintSample()
- #========================================================================
- # Author: Eric Hewitt
- # Description: Prints the current document and then reopens the pagesetup
- # dialog.
- # Parameters: None
- # Returns: Nothing
- # Examples: PrintSample();
- #========================================================================
- # History:
- #
- #########################################################################
- TASK PrintSample()
- begin
- if (global testPrint)
- begin
- SelectButton('OK'); # close page setup dialog
-
- ### Remember front window
- frontWindow := match [window o:1]!;
-
- if (SelectMenuItem('Print','File'))
- begin
- SpecialKey(returnKey,"Return Key"); # close print dialog
- LogStr("Printing Document");
- end;
-
- ### Wait for frontWind to become the front window again
- while not (match [window o:1 t:frontWindow.t]!);
-
- if not (SelectMenuItem('Page Setup','File'))
- begin
- LogStr("#### ERROR: Could not open page setup. Exiting script");
- exit;
- end;
- end;
- end;
-
- #########################################################################
- # PrintAlert()
- #========================================================================
- # Author: Eric Hewitt
- # Description: Logs the Static text from an alert dialog.
- # Parameters: none
- # Return Values: none
- # Examples: PrintAlert();
- #========================================================================
- # History:
- #
- #########################################################################
- TASK PrintAlert()
- begin
- messages := collect [staticText w:[window o:1]];
- if (card messages > 0)
- begin
- first := messages[1].t;
- LogStr("!@#$% ALERT: {first}");
- end;
- if (card messages > 1)
- begin
- second := messages[2].t;
- LogStr("!@#$% ALERT: {second}");
- end;
- end;
-
- ########################################################################
- # PageSetup( WhichDevice )
- #=======================================================================
- # Author: KTA
- # Description: For PageSetup routines
- # Parameters: WhichDevice - device
- # PagSetupMI - pageSetup menuItem descriptor
- # Returns: None
- #=======================================================================
- # History:
- # KTA 7/8/93 International support: Pass in PageSetup menuItem descriptor
- # KTA 7/19/93 changed descriptor so it is not embedded in a list
- # KTA 8/24/93 TCS stack parity check
- ########################################################################
- TASK PageSetup(WhichDevice := "LaserWriter", PagSetupMI := {"Page Setup", "File"})
- begin
- if ( WhichDevice = "LaserWriter")
- begin
- TCSStart({ 1, global kTCSetPageSetup },"Select 'Page Setup'");
- TCSEnd({ 1, global kTCSetPageSetup }, SelectMenuItem(PagSetupMI[1], PagSetupMI[2])); #To select Page SetUp…
- wait(1);
- PageSetupDesc:= match[window o:1]!;
- TCSStart({ 2, global kTCSetPageSetup },"Dismiss the Page Setup Dialog");
- SpecialKey(returnKey, 'Return Key'); #To Select the Default-'OK'
- wait(1);
- if not FindWindow(PageSetupDesc)
- TCSEnd({ 2, global kTCSetPageSetup },1);
- else
- TCSEnd({ 2, global kTCSetPageSetup },0);
- end;
- end; # PageSetup()
-
- ########################################################################
- # Print()
- #=======================================================================
- # Author: KTA
- # Description: For Print routines
- # Parameters: PrintMI - menuItem descriptor
- # Returns: None
- #=======================================================================
- # History:
- # KTA 7/8/93 International Support: Pass in MenuItem descriptor
- ########################################################################
- TASK Printer(PrintMI := {"Print", "File"})
- begin
- if (global PrintTest)
- begin
- SelectMenuItem(PrintMI[1], PrintMI[2]); #To select Print
- wait(2);
- SpecialKey(returnKey, 'Return Key'); #To Select the Default-'OK'
- end;
- end; # Printer()
-